package edu.hwadee.action;



import com.opensymphony.xwork2.ModelDriven;

import edu.hwadee.entity.Staff;

/**
 * ClassName: StafflAction 
 * @Description: ����Ϊ��Ա��Ϣ���Action�࣬���ڹ������ʻ�����Ϣ����ɾ��Ĳ�����Ϊ��Ա��Ϣ����ģ��
 * 				ֻ��ϵͳ����Ա���ܲ���
 * @author chenjianhao
 * @date 2018��8��14��
 */
public class StaffAction extends BasicAction implements ModelDriven<Staff>{
	

	private static final long serialVersionUID = 1L;
	private Staff staff;
	private int staffComplementId;

	public String addStaff() {
		if(staff != null){
			boolean success = getStaffServiceImpl().save(staff);
			if(success)
				return "success";
		}
		return "fail";
	}
	
	public String deleteStaff()
	{
		if(staff != null){
			boolean success = getStaffServiceImpl().delete(staff);
			if(success)
				return "success";
		}
		return "fail";
	}
	
	public String updateStaff()
	{
		if(staff != null){
			boolean success = getStaffServiceImpl().update(staff);
			if(success)
				return "success";
		}
		return "fail";
	}
	
	public void searchStaff(Staff staff)
	{
		/*try
		{
			if(staff != null){List<Staff> s = getStaffServiceImpl().search(staff);}
		}
		catch(Exception ex)
		{
			return "fail";
		}
		return "success";*/
		this.staff=staff;
	}
	
	public String searchById(Integer staffId)
	{
		
		if(staff.getStaffId()==staffId)
			return "success";
		else return "fail";
	}
	
	public Staff getStaff()
	{
		return staff;
	}
	public void setStaff(Staff staff)
	{
		this.staff=staff;
	}
	/*public void deleteStaff(Staff staff)
	{
		delete
	}*/
	public int getStaffComplementId() {
		return staffComplementId;
	}

	public void setStaffComplementId(int staffComplementId) {
		this.staffComplementId = staffComplementId;
	}
	
	@Override
	public Staff getModel() {
		// TODO Auto-generated method stub
		return staff;
	}
}
